<template>
  <div class="zhuS">
    <div v-for="(item, index) in arrt">
      <div style="display: flex;">
        <div style="width: 30px;text-align: center;height: 20px;font-weight: bold;color: brown;">{{ index + 1 }}</div>
        <div style="width: 230px;">
          <div style="width: 230px;word-wrap : break-word;overflow: hidden;">{{ item.oth1 }}</div>
          <div style="font-size: 10px;color: olivedrab;width: 230px;word-wrap : break-word;overflow: hidden;">//{{
            item.oth2 }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import robot from 'robotjs'
import { ipcRenderer } from 'electron'
import { mapState } from 'vuex'
export default {
  data() {
    return {
      arr1: [],
      arr2: [],
      arrt: [],
      oldScrollTop: 0,
      container: null,
    
    }
  },
  created() {
    ipcRenderer.on('print-message', (event, message) => {
      console.log('监听');
      if (message) {
        console.log('主进程打印的内容:', JSON.parse(message));
        var jianJia = JSON.parse(message)
        if (jianJia.clear == 1) {
          this.arrt = []
        } else {
          var container = document.querySelector('.zhuS');
          if (container.scrollHeight > 850) {
            container.scrollTop = container.scrollHeight + 20
          }
          this.arrt.push({ oth1: jianJia.arr1[jianJia.count - 1], oth2: jianJia.arr2[jianJia.count - 1] })


          console.log(container.scrollHeight);
          console.log(container.scrollTop);

          // if (this.container.scrollHeight > this.container.clientHeight) {
          //   this.container.scrollTop = this.container.scrollHeight;
          // }

        }

      }
    })

  },
  computed: {
    ...mapState(['datas'])
  },
  watch: {
  },
  mounted() {
  },
  methods: {
  }

}
</script>

<style >
.zhuS {
  width: 280px;
  height: 870px;
  max-height: 870px;
  margin: 0 auto;
  background-color: white;
  overflow: auto;
  /* overflow-y: scroll; */
  /* 设置滚动条停留在底部 */
  /* scroll-behavior: smooth; */


}
</style>